package cc.yugu.yhdw.common.protocol.msg02;

import cc.yugu.yhdw.common.protocol.MsgCode;
import cc.yugu.yhdw.common.tool.netty.TypeOperator;
import io.netty.buffer.ByteBuf;

import java.util.ArrayList;
import java.util.List;

public class Msg022000020 extends Msg022 {

    public List<Operation> operationList = new ArrayList<Operation>();

    @Override
    public int getMsgCode() {
        return MsgCode.MSG_022000020.getCode();
    }

    @Override
    public void writeData(ByteBuf buffer) {
        writeRtn(buffer);

        buffer.writeInt(operationList.size());
        for(Operation e : operationList) {
            e.write(buffer);
        }
    }

    public static class Operation extends TypeOperator {

        public String boxNum;
        public String batteryNo;
        public String operationMobile;
        public byte OperationType;
        public long OperationTime;

        public void write(ByteBuf buffer) {
            writeString(buffer, boxNum);
            writeString(buffer, batteryNo);
            writeString(buffer, operationMobile);
            buffer.writeByte(OperationType);
            buffer.writeLong(OperationTime);
        }
    }

}
